function Particle()
{
	this.positionX = 0.0;
	this.positionY = 0.0;
	
	this.velocityX = 0.0;
	this.velocityY = 0.0;
	
	// The time elapsed since particle came alive.
	this.time = 0;
	
	// How long the particle can be alive.
	this.life = 0;
	
	this.active = false;
	
	// The angle the particle is emitted towards
	this.angle = 0;
	
	// The initial speed
	this.speed = 0.0;

	this.colorRatio = 0.0;
	this.r = 255;
	this.g = 0;
	this.b = 0;
}

Particle.prototype =
{
	update: function(timeDelta) {
		this.time += timeDelta;
		if (this.time >= this.life)
		{
			// The particle has now exceeded its lifetime
			// deactivate it.
			this.active = false;
		}
		else
		{
			this.updatePosition();
		}
		return this.active;
	},

	deactivate: function() {
		this.active = false;
	},

	activate: function() {
		this.active = true;
	},

	isActive: function() {
		return this.active;
	},

	calcInitialVelocity: function() {
		this.velocityX = this.speed * Gl_cos[this.angle];
		this.velocityY = this.speed * Gl_sin[this.angle];
	},

	updateVelocity: function(accelerationX, accelerationY) {
		this.velocityX += -accelerationX;
		if (this.velocityX > 4.0)
			this.velocityX = 4.0;
		else if (this.velocityX < -4.0)
			this.velocityX = -4.0;

		this.velocityY += -accelerationY;
		if (this.velocityY > 4.0)
			this.velocityY = 4.0;
		else if (this.velocityY < -4.0)
			this.velocityY = -4.0;
//debug4.innerHTML = this.velocityX+","+ this.velocityY;
	},

	updatePosition: function() {
		this.positionX += this.velocityX;
		this.positionY += this.velocityY;
	},

	setPosition: function(posX, posY) {
		this.positionX = posX;
		this.positionY = posY;
	},

	draw: function() {
		var dt = this.life - this.time;
		if (dt < 0)
			dt = 0;
		dt = Math.floor(dt / this.colorRatio) + 10;
		if (dt > 255)
			dt = 255;

		ctx.fillStyle = "rgb(" + dt + ",0,0)";
		ctx.fillRect(Math.floor(this.positionX), Math.floor(this.positionY), 4, 4);
	}
};